home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / TroyReturns.dxr / 00007_Player handlers.ls < prev    next >
Encoding:
Text File  |  2002-01-31  |  14.6 KB  |  451 lines

  1. on initializeplayer
  2.   global playerLocData, playerSO, playerInventory
  3.   playerLocData = [1, 0, point(225, 100), 0, 0, #Walk, #L, 1, 0, 0, 0, 0, 0]
  4.   puppetSprite(playerSO, 1)
  5.   set the member of sprite playerSO to "player Orb"
  6.   set the ink of sprite playerSO to 36
  7.   sprite(playerSO).locZ = 200
  8.   playerInventory[2] = 0
  9. end
  10.  
  11. on movePlayer
  12.   global playerLocData, terrainData_Type, playerViewpoint, screenDimensions, inputString, playerSO, screenTileSize, anchorViewPoint, superPowers, monsterHitArea, monsterHarmArea, monsterSO, monsterData, bossDamageTaken, rumbleOffset, killOnlyOnce, bossIntro, jumpKeyMap, playerHealth
  13.   hitSpikes = 0
  14.   anchorViewPoint = point(0, 0)
  15.   enemyHit = 0
  16.   playerHit = 0
  17.   if playerLocData[1] = 1 then
  18.     repeat with wmon = 1 to count(monsterHitArea)
  19.       if (inside(playerLocData[3] + point(0, 50), monsterHitArea[wmon]) = 1) and (playerLocData[2] = 0) then
  20.         enemyHit = wmon
  21.         next repeat
  22.       end if
  23.       if (inside(playerLocData[3] + point(0, 40), monsterHarmArea[wmon]) = 1) and (playerLocData[2] = 1) then
  24.         playerHit = 1
  25.         next repeat
  26.       end if
  27.       if (inside(playerLocData[3] + point(20, -40), monsterHarmArea[wmon]) = 1) and (playerLocData[10] = 0) then
  28.         playerHit = 1
  29.         next repeat
  30.       end if
  31.       if (inside(playerLocData[3] + point(-20, -40), monsterHarmArea[wmon]) = 1) and (playerLocData[10] = 0) then
  32.         playerHit = 1
  33.         next repeat
  34.       end if
  35.       if inside(playerLocData[3] + point(20, 0), monsterHarmArea[wmon]) = 1 then
  36.         playerHit = 1
  37.         next repeat
  38.       end if
  39.       if inside(playerLocData[3] + point(-20, 0), monsterHarmArea[wmon]) = 1 then
  40.         playerHit = 1
  41.       end if
  42.     end repeat
  43.   end if
  44.   if bossDamageTaken = 1 then
  45.     playerHit = 1
  46.   end if
  47.   if playerHit = 1 then
  48.     rpoint = playerLocData[3]
  49.     playerLocData[1] = 0
  50.   end if
  51.   if bossIntro > 0 then
  52.     inputString = [0, 0, 0, 0, 0]
  53.   else
  54.     if playerLocData[1] = 1 then
  55.       harvestinput()
  56.       playerLocData[11] = 0
  57.     else
  58.       inputString = [0, 0, 0, 0, 0]
  59.       playerLocData[11] = playerLocData[11] + 1
  60.     end if
  61.   end if
  62.   jumpKeyMap = 4
  63.   if (playerLocData[2] = 1) and (inputString[jumpKeyMap] = 1) then
  64.     playerLocData[5] = -30
  65.     playerLocData[2] = 0
  66.     if playerLocData[13] = 0 then
  67.       playSound("Jump SFX")
  68.     end if
  69.   else
  70.     if enemyHit <> 0 then
  71.       playerLocData[5] = -45
  72.       playerLocData[2] = 0
  73.       monsterData[enemyHit][5] = monsterData[enemyHit][5] + 1
  74.       playSound("Jump On Enemy SFX")
  75.     else
  76.       if (playerLocData[2] = 0) and (inputString[jumpKeyMap] = 0) then
  77.         if playerLocData[5] < -10 then
  78.           playerLocData[5] = -10
  79.         end if
  80.       end if
  81.     end if
  82.   end if
  83.   if inputString[4] = 1 then
  84.     bData1 = checkSolidpoint(playerLocData[3])
  85.     bData2 = checkSolidpoint(playerLocData[3] + point(0, -40))
  86.     if (bData1[1] = 3) and (bData2[1] = 3) then
  87.       if (inputString[1] = 0) and (inputString[2] = 0) then
  88.         playerLocData[5] = 0
  89.         playerLocData[2] = 1
  90.         playerLocData[13] = 1
  91.       end if
  92.     end if
  93.   end if
  94.   if playerLocData[13] = 1 then
  95.     if (inputString[1] = 1) or (inputString[2] = 1) then
  96.       if inputString[4] = 1 then
  97.         playerLocData[5] = -15
  98.         playerLocData[2] = 0
  99.         playerLocData[13] = 0
  100.       else
  101.         playerLocData[5] = 0
  102.         playerLocData[2] = 0
  103.         playerLocData[13] = 0
  104.       end if
  105.     else
  106.       if inputString[5] = 1 then
  107.         playerLocData[5] = -20
  108.         playerLocData[2] = 0
  109.         playerLocData[13] = 0
  110.       else
  111.         if inputString[4] = 1 then
  112.           bData2 = checkSolidpoint(playerLocData[3] + point(0, -40))
  113.           if bData2[1] = 3 then
  114.             playerLocData[3] = playerLocData[3] + point(0, -5)
  115.           end if
  116.           if ((playerLocData[3][1] + 25) mod 50) < 25 then
  117.             playerLocData[3][1] = playerLocData[3][1] - 2
  118.           else
  119.             playerLocData[3][1] = playerLocData[3][1] + 2
  120.           end if
  121.         else
  122.           if inputString[3] = 1 then
  123.             bData2 = checkSolidpoint(playerLocData[3] + point(0, 40))
  124.             if bData2[1] = 3 then
  125.               playerLocData[3] = playerLocData[3] + point(0, 5)
  126.             end if
  127.             if ((playerLocData[3][1] + 25) mod 50) < 25 then
  128.               playerLocData[3][1] = playerLocData[3][1] - 2
  129.             else
  130.               playerLocData[3][1] = playerLocData[3][1] + 2
  131.             end if
  132.           end if
  133.         end if
  134.       end if
  135.     end if
  136.   end if
  137.   if superPowers = 1 then
  138.     maxHSpeed = 12
  139.   else
  140.     maxHSpeed = 10
  141.   end if
  142.   if (inputString[1] = 1) and (playerLocData[10] = 0) then
  143.     playerLocData[4] = playerLocData[4] - 3
  144.     if playerLocData[4] < (0 - maxHSpeed) then
  145.       playerLocData[4] = 0 - maxHSpeed
  146.     end if
  147.     playerLocData[7] = #left
  148.     playerLocData[6] = #Run
  149.     anchorViewPoint[1] = -75
  150.   else
  151.     if (inputString[2] = 1) and (playerLocData[10] = 0) then
  152.       playerLocData[4] = playerLocData[4] + 3
  153.       if playerLocData[4] > maxHSpeed then
  154.         playerLocData[4] = maxHSpeed
  155.       end if
  156.       playerLocData[7] = #right
  157.       playerLocData[6] = #Run
  158.       anchorViewPoint[1] = 75
  159.     else
  160.       repeat with whichRep = 1 to 2
  161.         if playerLocData[4] > 0 then
  162.           playerLocData[4] = playerLocData[4] - 1
  163.           next repeat
  164.         end if
  165.         if playerLocData[4] < 0 then
  166.           playerLocData[4] = playerLocData[4] + 1
  167.         end if
  168.       end repeat
  169.       case playerLocData[7] of
  170.         #left:
  171.           anchorViewPoint[1] = -50
  172.         #right:
  173.           anchorViewPoint[1] = 50
  174.       end case
  175.       playerLocData[6] = #idle
  176.     end if
  177.   end if
  178.   checkWallState = 1
  179.   if playerLocData[4] > 0 then
  180.     groundTest = playerLocData[3] + point(25, 0)
  181.     spikeTest = playerLocData[3] + point(20, 0)
  182.     checkWallState = 1
  183.   else
  184.     if playerLocData[4] < 0 then
  185.       groundTest = playerLocData[3] - point(30, 0)
  186.       spikeTest = playerLocData[3] - point(25, 0)
  187.       checkWallState = 1
  188.     else
  189.       checkWallState = 0
  190.     end if
  191.   end if
  192.   if checkWallState = 1 then
  193.     testTheWall1 = checkSolidpoint(groundTest + point(0, 40))
  194.     testTheWall2 = checkSolidpoint(groundTest + point(0, 0))
  195.     testTheWall3 = checkSolidpoint(groundTest + point(0, -40))
  196.     testSpikeWall1 = checkSolidpoint(spikeTest + point(0, 30))
  197.     testSpikeWall2 = checkSolidpoint(spikeTest + point(0, 0))
  198.     testSpikeWall3 = checkSolidpoint(spikeTest + point(0, -30))
  199.     if (testSpikeWall1[2] = 10) or (testSpikeWall2[2] = 10) or (testSpikeWall3[2] = 10) then
  200.       hitSpikes = 1
  201.     end if
  202.     if (testSpikeWall1[2] = 11) or (testSpikeWall2[2] = 11) or (testSpikeWall3[2] = 11) then
  203.       hitSpikes = 2
  204.     end if
  205.     if (testTheWall1[1] = 1) or (testTheWall2[1] = 1) or (testTheWall3[1] = 1) then
  206.       playerLocData[4] = 0
  207.       playerLocData[3][1] = playerLocData[3][1] - (playerLocData[3][1] mod screenTileSize) + integer(screenTileSize / 2.0)
  208.     end if
  209.   end if
  210.   if playerLocData[2] = 0 then
  211.     playerLocData[5] = playerLocData[5] + 2
  212.     verticalMove = playerLocData[5]
  213.     if verticalMove < -15 then
  214.       verticalMove = -15
  215.     end if
  216.     if verticalMove > 15 then
  217.       verticalMove = 15
  218.     end if
  219.     playerLocData[3][2] = playerLocData[3][2] + verticalMove
  220.     if playerLocData[5] > 0 then
  221.       groundTest = playerLocData[3] + point(0, 50)
  222.       testTheGround1 = checkSolidpoint(groundTest + point(15, 0))
  223.       testTheGround2 = checkSolidpoint(groundTest + point(-15, 0))
  224.       testAbovePlatform1 = checkSolidpoint(groundTest + point(15, 0) - point(0, verticalMove))
  225.       testAbovePlatform2 = checkSolidpoint(groundTest + point(-15, 0) - point(0, verticalMove))
  226.       testSpikeGround1 = checkSolidpoint(groundTest + point(10, -10))
  227.       testSpikeGround2 = checkSolidpoint(groundTest + point(-10, -10))
  228.       if (testSpikeGround1[2] = 10) or (testSpikeGround2[2] = 10) then
  229.         hitSpikes = 1
  230.       end if
  231.       if (testSpikeGround1[2] = 11) or (testSpikeGround2[2] = 11) then
  232.         hitSpikes = 2
  233.       end if
  234.       foundPlatform = 0
  235.       if (testTheGround1[1] = 2) or (testTheGround2[1] = 2) then
  236.         if (testAbovePlatform1[1] = 0) or (testAbovePlatform2[1] = 0) then
  237.           foundPlatform = 1
  238.         end if
  239.       end if
  240.       if (testTheGround1[1] = 1) or (testTheGround2[1] = 1) then
  241.         playerLocData[5] = 0
  242.         playerLocData[2] = 1
  243.         playerLocData[3][2] = playerLocData[3][2] - ((playerLocData[3][2] + 50) mod screenTileSize)
  244.       else
  245.         if foundPlatform = 1 then
  246.           playerLocData[5] = 0
  247.           playerLocData[2] = 1
  248.           playerLocData[3][2] = playerLocData[3][2] - ((playerLocData[3][2] + 50) mod screenTileSize)
  249.         end if
  250.       end if
  251.     else
  252.       groundTest = playerLocData[3] - point(0, 50)
  253.       testTheGround1 = checkSolidpoint(groundTest + point(15, 0))
  254.       testTheGround2 = checkSolidpoint(groundTest + point(-15, 0))
  255.       testAbovePlatform1 = checkSolidpoint(groundTest + point(15, 0) - point(0, verticalMove))
  256.       testAbovePlatform2 = checkSolidpoint(groundTest + point(-15, 0) - point(0, verticalMove))
  257.       testSpikeGround1 = checkSolidpoint(groundTest + point(10, -10))
  258.       testSpikeGround2 = checkSolidpoint(groundTest + point(-10, -10))
  259.       if (testSpikeGround1[2] = 10) or (testSpikeGround2[2] = 10) then
  260.         hitSpikes = 1
  261.       end if
  262.       if (testSpikeGround1[2] = 11) or (testSpikeGround2[2] = 11) then
  263.         hitSpikes = 2
  264.       end if
  265.       foundPlatform = 0
  266.       if (testTheGround1[1] = 1) or (testTheGround2[1] = 1) then
  267.         punchBlock(groundTest)
  268.         playerLocData[5] = 0
  269.       else
  270.         if foundPlatform = 1 then
  271.           playerLocData[5] = 0
  272.           playerLocData[2] = 1
  273.           playerLocData[3][2] = playerLocData[3][2] - ((playerLocData[3][2] + 50) mod screenTileSize)
  274.         end if
  275.       end if
  276.     end if
  277.   end if
  278.   groundTest = playerLocData[3] + point(0, 50)
  279.   testTheGround1 = checkSolidpoint(groundTest + point(20, 0))
  280.   testTheGround2 = checkSolidpoint(groundTest + point(-20, 0))
  281.   testTheGround3 = checkSolidpoint(groundTest + point(0, -10))
  282.   if (testTheGround3[2] = 10) or (testTheGround3[2] = 11) then
  283.     hitSpikes = 1
  284.   end if
  285.   if (testTheGround1[1] = 0) and (testTheGround2[1] = 0) then
  286.     playerLocData[2] = 0
  287.     if playerLocData[5] >= 0 then
  288.       playerLocData[6] = #Fall
  289.     else
  290.       playerLocData[6] = #jump
  291.     end if
  292.   else
  293.     conveyRight = 0
  294.     conveyLeft = 0
  295.     case testTheGround1[2] of
  296.       2:
  297.         conveyRight = conveyRight + 1
  298.       3:
  299.         conveyLeft = conveyLeft + 1
  300.     end case
  301.     case testTheGround2[2] of
  302.       2:
  303.         conveyRight = conveyRight + 1
  304.       3:
  305.         conveyLeft = conveyLeft + 1
  306.     end case
  307.     case testTheGround3[2] of
  308.       2:
  309.         conveyRight = conveyRight + 1
  310.       3:
  311.         conveyLeft = conveyLeft + 1
  312.     end case
  313.     if conveyRight > conveyLeft then
  314.       playerLocData[3] = playerLocData[3] + point(3, 0)
  315.     else
  316.       if conveyRight < conveyLeft then
  317.         playerLocData[3] = playerLocData[3] - point(3, 0)
  318.       end if
  319.     end if
  320.   end if
  321.   if inputString[3] = 1 then
  322.     if playerLocData[10] < 3 then
  323.       playerLocData[10] = playerLocData[10] + 1
  324.     end if
  325.   else
  326.     if playerLocData[10] > 0 then
  327.       playerLocData[10] = playerLocData[10] - 1
  328.     end if
  329.   end if
  330.   if playerLocData[10] <> 0 then
  331.     playerLocData[6] = #Crouch
  332.   end if
  333.   playerLocData[3][1] = playerLocData[3][1] + playerLocData[4]
  334.   if (hitSpikes = 1) or (hitSpikes = 2) then
  335.     playerLocData[1] = 0
  336.   end if
  337.   if playerLocData[12] > 1 then
  338.     playerLocData[1] = 1
  339.     playerLocData[12] = playerLocData[12] - 1
  340.     set the foreColor of sprite playerSO to random(255)
  341.   else
  342.     set the foreColor of sprite playerSO to 255
  343.     if playerLocData[1] = 0 then
  344.       if playerHealth > 1 then
  345.         playerLocData[1] = 1
  346.         playerLocData[12] = 40
  347.         playerHealth = playerHealth - 1
  348.         playSound("Lose heart SFX")
  349.         rpoint = playerLocData[3]
  350.       else
  351.         playerLocData[6] = #Dead
  352.       end if
  353.     end if
  354.   end if
  355.   if playerLocData[13] = 1 then
  356.     playerLocData[6] = #Climb
  357.   end if
  358.   if superPowers = 1 then
  359.     playerTitle = "Super"
  360.   else
  361.     playerTitle = "Normal"
  362.   end if
  363.   case playerLocData[6] of
  364.     #Run:
  365.       playerLocData[9] = playerLocData[9] + 1
  366.       if playerLocData[9] > 1 then
  367.         playerLocData[8] = playerLocData[8] + 1
  368.         if playerLocData[8] > 4 then
  369.           playerLocData[8] = 1
  370.         end if
  371.         playerLocData[9] = 0
  372.       end if
  373.       membername = "Player " & playerTitle & " Walk" & string(playerLocData[8])
  374.     #idle:
  375.       membername = "Player " & playerTitle & " Idle"
  376.     #jump:
  377.       membername = "Player " & playerTitle & " Jump"
  378.     #Fall:
  379.       membername = "Player " & playerTitle & " Fall"
  380.     #Crouch:
  381.       membername = "Player " & playerTitle & " Crouch"
  382.     #Dead:
  383.       membername = "Player " & playerTitle & " Dead"
  384.     #Climb:
  385.       cMod = (playerLocData[3][2] / 15 mod 2) + 1
  386.       membername = "Player " & playerTitle & " Climb " & string(cMod)
  387.   end case
  388.   if (playerLocData[3][2] >= 550) and (playerLocData[1] = 1) then
  389.     playerLocData[1] = 0
  390.     playerLocData[11] = 45
  391.     playerHealth = 0
  392.     if killOnlyOnce = 1 then
  393.       playSound("T-Roy Dies SFX")
  394.       killOnlyOnce = 0
  395.     end if
  396.     extraBounce = -6
  397.   else
  398.     extraBounce = 0
  399.   end if
  400.   case playerLocData[7] of
  401.     #left:
  402.       sprite(playerSO).flipH = 1
  403.     #right:
  404.       sprite(playerSO).flipH = 0
  405.   end case
  406.   if playerLocData[1] = 0 then
  407.     if playerLocData[11] < 45 then
  408.       set the loc of sprite playerSO to playerLocData[3] - playerViewpoint + rumbleOffset
  409.       set the member of sprite playerSO to membername
  410.       sprite(playerSO).visible = 1
  411.       if playerLocData[11] = 15 then
  412.         playSound("T-Roy Dies SFX")
  413.       end if
  414.     else
  415.       if playerLocData[11] = 45 then
  416.         addPickup(3, 5, playerLocData[3] + point(-25, 0), point((random(50) - 25) / 10.0, -16 - random(4)))
  417.         repeat with wAdd = 1 to 30
  418.           addPickup(3, random(4), playerLocData[3] + point(-25, 0), point((random(50) - 25) / 10.0, -2 - random(12) + extraBounce))
  419.         end repeat
  420.         sprite(playerSO).visible = 0
  421.       end if
  422.     end if
  423.   else
  424.     sprite(playerSO).visible = 1
  425.     set the loc of sprite playerSO to playerLocData[3] - playerViewpoint + rumbleOffset
  426.     set the member of sprite playerSO to membername
  427.   end if
  428.   if inputString[3] = 1 then
  429.     anchorViewPoint[2] = 100
  430.   else
  431.     anchorViewPoint[2] = 0
  432.   end if
  433.   anchorViewPoint = anchorViewPoint - point(290, 250) + playerLocData[3]
  434. end
  435.  
  436. on setPMode modeType, modeFlip
  437.   global playerLocData
  438.   if (playerLocData[6] <> modeType) or (playerLocData[7] <> modeFlip) then
  439.     playerLocData[8] = 0
  440.     playerLocData[9] = 0
  441.   end if
  442.   playerLocData[6] = #modeType
  443.   playerLocData[7] = modeFlip
  444. end
  445.  
  446. on addScore scoreValue
  447.   global playerScore, levelScore, updateScoreDisplayNOW
  448.   levelScore = levelScore + scoreValue
  449.   updateScoreDisplayNOW = 1
  450. end
  451.